package com.example.localareanetworkchat

import org.junit.Test

import org.junit.Assert.*

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }

    @Test
    fun ipTest(){
        val ip = "192.168.101.2"
        val ip_part = ip.split(".")

        var result = 0

        result = result or ip_part[0].toInt()
        result = result.shl(8)
        result = result or ip_part[1].toInt()
        result = result.shl(8)
        result = result or ip_part[2].toInt()
        result = result.shl(8)
        result = result or ip_part[3].toInt()

        println(result)

        println(Integer.toHexString(result).uppercase())
        // println(Integer.toHexString(ip_part[0].toInt()).uppercase())
    }

    @Test
    fun filterTest(){
        val list = arrayListOf(1, 2, 3)
        list.filter {
            it > 2
        }.forEach {
            println(it)
        }
    }

    @Test
    fun hexStrTest(){
        val ipStr = "0A000210"
        var ip = ""
        ip += ipStr.substring(0, 2).toLong(16).toString() + "."
        ip += ipStr.substring(2, 4).toLong(16).toString() + "."
        ip += ipStr.substring(4, 6).toLong(16).toString() + "."
        ip += ipStr.substring(6, 8).toLong(16).toString()

        println(ip)

    }
}